import { Message } from 'element-ui';
import store from '../store';

const errorHandle = err => {
  switch (err.response.status) {
    case 401:
      Message.error('401 (Token has expired)');
      setTimeout(() => {
        store.commit('user/signOut', '1');
      }, 1000);
      break;
    case 404:
      Message.error('404 (Not Found)');
      break;
    case 500:
      Message.error('500 (Internal Server Error)');
      break;
    default:
      Message.error('Unknown Error');
  }
};

export default errorHandle;
